package com.example.yk

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.widget.TextView
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.yk.databinding.ActivitySearchBinding
import com.example.yk.entity.SearchEntity
import com.example.zk3.mvvm.BaseActivity
@Route(path = "/app/SearchActivity")
class SearchActivity : BaseActivity<ActivitySearchBinding,SearchViewModel>() {
    val list = mutableListOf<SearchEntity>()
    override fun initData() {
        viewModel.searchSuccess.observe(this){
            if(it.success){
                binding.group.removeAllViews()
                list.clear()
                list.addAll(it.data)
                list.forEach {
                    val view = layoutInflater.inflate(R.layout.item_grou,null)
                    view.findViewById<TextView>(R.id.chip).text = it.name
                    binding.group.addView(view)
                }
            }
        }
    }

    override fun initView() {
        viewModel.searchtj()
    }

    override fun getLayout(): Int  = R.layout.activity_search

    override fun getViewModel(): Class<SearchViewModel>  = SearchViewModel::class.java

}